#pragma once

#include <QtWidgets/QWidget>
#include "ui_MyWebInteractive.h"
#include <condition_variable>
#include <mutex>

QT_BEGIN_NAMESPACE
namespace Ui { class MyWebInteractiveClass; };
QT_END_NAMESPACE

class MyWebInteractive : public QWidget
{
    Q_OBJECT

public:
    MyWebInteractive(QWidget *parent = nullptr);
    
    ~MyWebInteractive();
private:
    void addLoop(const QString& uuid,QEventLoop* pLoop);
    void removeLoop(const QString& uuid);
signals:
    void signalRunJsOver(const QString& uuid);
private slots:
    void on_callJSBtn_clicked();
private:
    Ui::MyWebInteractiveClass *ui;
    std::mutex m_callJs_mtx;
    QMap<QString, QEventLoop*> m_loop_map;
    std::condition_variable m_callJs_cv;
    bool m_js_returned = true;
};
